package com.eastcom.groovy.config

import com.eastcom.groovy.config.GroovyScript;
import com.eastcom.groovy.tools.db.DerByUtil;
import com.eastcom.groovy.tools.file.GroovyUtil;
import com.eastcom.groovy.tools.file.JaxbUtil;

import org.apache.commons.logging.Log
import org.apache.commons.logging.LogFactory
import com.eastcom.groovy.context.TaskContext
import javax.xml.bind.annotation.XmlAccessType
import javax.xml.bind.annotation.XmlAccessorType
import javax.xml.bind.annotation.XmlElement
import javax.xml.bind.annotation.XmlTransient

/**
 * Created by yuanyue on 2014-08-03.
 */
@XmlAccessorType(XmlAccessType.FIELD)
//@javax.xml.bind.annotation.XmlSeeAlso([com.eastcom.groovy.config.db.DbTaskConfig.class])
class TaskConfig{
	private static Log logger = LogFactory.getLog(TaskConfig.class)
	static final String TASK_CONFIG = "TASK_CONFIG"
	@XmlElement(name = "type")
	String type
	@XmlElement(name = "cron")
	String cron;
	@XmlElement(name = "name")
	String name;
	@XmlElement(name = "bucai-cycle")
	long buCaiCycle;
	@XmlElement(name = "bucai-cron")
	String buCaiCron;
	@XmlElement(name = "extern")
	ExternConfig extern;
	@XmlTransient
	String rootPath
	@Override
	public String toString() {
		return "AbsTaskConfig{" +
		"type='" + type + '\'' +
		", cron='" + cron + '\'' +
		", name='" + name + '\'' +
		", buCaiCycle=" + buCaiCycle +
		", buCaiCron='" + buCaiCron + '\'' +
		'}';
	}
	Object initConfig(String jobId,String rootPath) {
		if (extern == null) {
			return null
		}
		this.rootPath = rootPath
		extern.executor.init(rootPath,jobId)
	}
}
